import { _decorator, Component, Label, Node, Toggle, Tween, tween, Vec3 } from 'cc';
import { StaminaSystem } from './StaminaSystem';
import { losChannel } from '../SDK/losChannel';
import loskc from '../SDK/loskc';
const { ccclass, property } = _decorator;

@ccclass('StaminaBuyUI')
export class StaminaBuyUI extends Component {

    @property(Node)
    public btnCancel: Node = null;
    @property(Node)
    public btnGet: Node = null;

    @property(Label)
    public label_num: Label = null;

    @property(Node)
    private videoSp: Node = null!;
    @property(Node)
    private videoLb: Node = null!;

    private _needWatchVideo: boolean = true;
    private _tw: Tween<Node> = null;
    private _currentVideoNode: Node = null;


    start() {
        this._currentVideoNode = this.videoSp;
        this.videoSp.active = true;
        this.videoLb.active = false;

        const chName = losChannel.instance().channel;
        switch (chName) {
            case 'ks':
                this.label_num.string = '×5';
                break;
            case 'ks2':
            case 'ks3':
                this.label_num.string = '×10';
                break
            default:
                break;
        }

        //this.clickToggleFunc();
        this._tw = tween(this.btnGet).sequence
            (
                tween(this.btnGet).to(0.4, { scale: new Vec3(1.12, 1.12, 1.12) }),
                tween(this.btnGet).to(0.4, { scale: new Vec3(1, 1, 1) })
            )
            .repeatForever()
            .start()
    }

    public onCancelClick() {
        this.node.removeFromParent();
    }
    /**
     * onGetClick
     */
    public onGetClick() {


        losChannel.instance().getChannel().showVideo(() => {

        }, () => {
            StaminaSystem.instance.addStamina(10)
            this.node.removeFromParent()
        })

    }
    // public onToggleClick(event: Event, customEventData: string) {
    //     this.clickToggleFunc()
    // }
    // private clickToggleFunc() {
    //     const chName = losChannel.instance().channel;
    //     switch (chName) {
    //         case 'ks1':
    //             {
    //                 this.updateDropButton()
    //             }
    //             break;
    //         case 'ks2':
    //         case 'ks3':
    //         case '':
    //         case 'honor':
    //             {
    //                 this.updatevideoSp();
    //             }
    //         default:
    //             {
    //                 this.updatevideoSp();
    //             }
    //             break;
    //     }
    // }
    // private updateDropButton() {
    //     if (this.toggle.isChecked) {
    //         this.btnCancel.active = false
    //         this.btnGet.setPosition(0, 0)
    //     }
    //     else {
    //         this.btnCancel.active = true
    //         this.btnGet.setPosition(130, 0)
    //     }
    // }
    // private updatevideoSp() {
    //     this._currentVideoNode.active = this.toggle.isChecked;
    //     this._needWatchVideo = this.toggle.isChecked;
    // }
    protected onEnable(): void {

    }
}